@extends('layouts.default') @section('main')
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <link rel="stylesheet" href="/css/chosen.css" />
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/js/chosen.jquery.min.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('activityapply/index')}}" class="tip-bottom">活动报名管理</a>
                <a href="#" class="current">编辑一个活动报名</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>编辑一个活动报名</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('activityapply/edit')}}" method="post" id="adForm" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label">姓名 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="name" placeholder="姓名" value="{{$list->name}}" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">手机号码 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="tel" placeholder="手机号码" value="{{$list->tel}}" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">公司名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="company" placeholder="公司名称" value="{{$list->company}}" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">留言 :</label>
                                    <div class="controls">
                                        <textarea  class="textarea_editor span11" rows="5" name="content" placeholder="留言">{{$list->content}}</textarea>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">场地名字的一部分（供搜索） :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="maker_search" value="" placeholder="输入场地名称的一部分，按下Enter键，搜索结果将出现在下面的多选框中，供选择" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">场地 :</label>
                                    <div class="controls">
                                        <select name="maker_id" id="maker_id">
                                            @if(isset($list->Maker->id))
                                                <option value="{{$list->Maker->id}}">{{$list->Maker->name}}</option>
                                            @else
                                                <option value="">请选择</option>
                                            @endif
                                        </select>
                                    </div>
                                </div>


                                <div class="form-actions">
                                    <input type="hidden" class="span11" name="formType" value="edit"  />
                                    <input type="hidden" class="span11" name="id" value="{{$list->id}}"/>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">编辑</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        $("input[name='maker_search']").keydown(function(event) {
            if (event.which == "13"){
                var param = {};
                param['name'] = $(this).val();
                ajaxRequest(param, '/maker/find', function (data) {
                    if (data.status) {
                        var html = '<option value="">请选择</option>';
                        $.each(data.message, function (i, n) {
                            html += "<option value='" + n.id + "'>" + n.name + "</option>";
                        });
                        $("#maker_id").html(html);
                        alert('恭喜，已经生成选项,请选择所需要的场地');
                    } else {
//                        var html = '<option value="">请按上面输入框的说明生成选项</option>';
//                        $("#post_id").html(html);
                        alert(data.message);
                    }
                });
            }
        });

        $("input[name='activity_search']").keydown(function(event) {
            if (event.which == "13"){
                var param = {};
                param['activity_search'] = $(this).val();

                ajaxRequest(param, '/live/find-activity', function (data) {
                    if (data.status) {
                        var html = '<option value="">请选择</option>';
                        $.each(data.message, function (i, n) {
                            html += "<option value='" + n.id + "'>" + n.subject + "</option>";
                        });
                        $("#activity_id").html(html);
                        alert('恭喜，已经生成选项,请选择所需要的目标');
                    } else {
                        var html = '<option value="">请按上面输入框的说明生成选项</option>';
                        $("#activity_id").html(html);
                        alert(data.message);
                    }
                });
            }
        });

        $("#doSave").click(function(){
            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });
    </script>
@stop
